<?php
namespace app\payqr\model;
use app\BaseModel;
class PayQrConfig extends BaseModel
{
    protected $name = 'lb_pay_qr_config';
    public function getinfo($where){
        $data = $this->where($where)->order('id','asc')->find();
        if(empty($data)){

            $this->addInfo(['uniacid'=>$where['uniacid']]);
            $data = $this->where($where)->order('id','asc')->find();
        }
        if($data){
            $data = transImagesOne($data->toArray(),['company_logo']);
        }
        return $data;
    }

    /**
     * User: chenniang
     * Date: 2019-11-18 11:30
     * @param $data
     * @return void
     * descption:添加数据
     */
    public function addInfo($data){
        $data['create_time'] = time();
        $data['update_time'] = time();
        $data['title']  = !empty($data['title'])?$data['title']:'';
        $data['company_name'] = !empty($data['company_name'])?$data['company_name']:'';
        $data['company_logo'] = !empty($data['company_logo'])?$data['company_logo']:'';
        $res = $this->insert($data);
        return $res;
    }
}